Ext.apply(Ext.form.VTypes,{
	
	 'long': function(value,field){
		return /^\d{3}\.\d{6}$/.test(value);
		//return true;
     },
     'longText': '经度输入错误(正确格式:XXX.XXXXXX)！',
     'lat': function(value,field){
     	return /^\d{2}\.\d{6}$/.test(value);
    	//return true;
     },
     'latText':'纬度输入错误(正确格式:XX.XXXXXX)！',
     'phone':function(value,field){
    	 return /(^[0-9]{8}$)|(^[0-9]{11}$)/.test(value);
     },
     'phoneText':'请输入8位或11位的有效号码！'
});
/*
 * Define CreateProject Class
 */
SimpleProjectPanel = function(){
    this.basicInfoPanel = new BasicInfoPanel();
    this.complaintPanel = new ComplaintPanel();
    
    SimpleProjectPanel.superclass.constructor.call(this, {
        id: "orderPanel",
        autoHeight: true,
        anchor:'100%',
        width:'99.9%',
        fileUpload: true,
        items: [this.basicInfoPanel,this.complaintPanel],
        buttons: [{
            xtype: "button",
            text: "保存",
            scope: this,
            handler: this.finishOrder
        }
        ],
        buttonAlign: "left",
        listeners: {
            afterrender: function(){
                Ext.select(".requiredlabel").insertHtml("beforeEnd", "<span style='color:red'>*</span>");
            }
        }
    });
}
Ext.extend(SimpleProjectPanel, Ext.form.FormPanel, {
    submitOrder: function(){
        this.finishOrder(true);
    },
    
    finishOrder: function(submit){
    
        if (!this.validateOrder()) {
            return;
        }
        var formdata = Ext.getCmp("orderPanel").getForm().getValues();
        var mask = new Ext.LoadMask(Ext.getBody(), {
            msg: "数据正在处理中，请稍等..."
        });
        
        var items = new Array();
        var records = Ext.getCmp("complaintPanel").getStore().getRange();
        for (var i = 0; i < records.length; i++) {
            items.push(records[i].data);
        }
        
        formdata.itemsJson = Ext.encode(items);
        formdata.submit = submit;
        
        mask.show();
        
        Ext.Ajax.request({
            url: "../popup/extjs/SubmitRoomProject.action",
            params: formdata,
            scope: this,
            success: function(response, options){
                mask.hide();
                Ext.getCmp("orderPanel").disable();
               	window.location.reload();
            },
            failure: function(){
                mask.hide();
                Ext.Msg.alert("提示", "项目创建失败!");
            }
        });
    },
    
    validateOrder: function(){
        if (!Ext.getCmp("orderPanel").getForm().isValid()) {
            return false;
        }
        return true;
    }
});

/*
 * Define BasicInfoPanel Class
 */
BasicInfoPanel = function(){
    //var customerStore = ""//StoreManager.getCustomerStore();
    //this.billToPartyStore.on("load", this.onBillToPartyStoreLoad);
	//区域
	var areaStore = StoreManager.getAreaStore();
	//区域性质
	var areaTypeStore = StoreManager.getAreaTypeStore();
	//项目分类
	var projectTypeStore = StoreManager.getProjectTypeStore();
	
    BasicInfoPanel.superclass.constructor.call(this, {
    	title: "覆盖延伸新建项目",
        autoHeight: true,
        frame: true,
        id: "basicorderPanel",
        layout: "column",
        anchor:'100%',
		width:'100%',
		labelWidth:100,
		labelPad:2,
		labelAlign:'right',
		bodyStyle:'padding:5px',
		defaults : {
			border:false,
			msgTarget : 'side'
		},
		items:[{
			columnWidth : .25,
			layout : 'form',
			bodyStyle : 'padding-right:5px;',
			border:false,
			defaults : {
				border:false,
				xtype : 'textfield',
				anchor : '100%'
			},
			items:[{
				id:'bizNumber',
				xtype:'textfield',
				name: "roomProject.bizNumber",
				readOnly:true,
	        	fieldLabel:'项目编号'
			}]
		},{
			columnWidth : .25,
			layout : 'form',
			bodyStyle : 'padding-left:5px;',
			border:false,
			defaults : {
				border:false,
				xtype : 'textfield',
				anchor : '100%'
			},
			items:[{
				id:'name',
				xtype:'textfield',
				name: "roomProject.name",
				fieldLabel:'<font color=red>*</font>项目名称',
				allowBlank:false,
				listeners:{
					blur:function(){
						/*var value=Ext.getCmp('name').getValue();
						 Ext.Ajax.request({
							url:encodeURI('room/roomProject!isName.action?name='+value),
							method:'POST',
							success: function(rst,msg){
								var text=Ext.decode(rst.responseText);
								if(text.success){
									if(text.message==1){
											Ext.Msg.show({
		   									title : '消息',
											msg : "<br />该项目名称已存在！",
											buttons : Ext.Msg.OK,
											icon : Ext.Msg.ERROR
		   								});
									}
								}
							}
						})*/
					}
				}
			}]
		},{
			columnWidth : .25,
			layout : 'form',
			bodyStyle : 'padding-left:5px;',
			border:false,
			defaults : {
				border:false,
				xtype : 'textfield',
				anchor : '100%'
			},
			items:[{
				xtype: "combo",
	            id: "areaCombo",
	            editable: false,
	            fieldLabel :'<font color=red>*</font>所属区域',
	            allowBlank:false,
	            valueField: "key",
	            displayField: "value",
	            hiddenName: "roomProject.area.id",
	            store: areaStore,
	            forceSelection: true,
	            mode: "remote",
	            triggerAction: "all",
	            emptyText:'请选择区域...',
	            listeners: {
	                select: function(){
	                    if (this.startValue != this.getValue()) {
	                        this.fireEvent("change");
	                    }
	                }
	            }
			}]
		},{
			columnWidth : .25,
			layout : 'form',
			bodyStyle : 'padding-left:5px;',
			border:false,
			defaults : {
				border:false,
				xtype : 'textfield',
				anchor : '100%'
			},
			items:[{
				xtype:'textfield',
				name: "roomProject.telphone",
				fieldLabel:'联系电话',
				vtype:'phone'
			}]
		},{
			columnWidth:1,
			layout:'form',
			bodyStyle:'padding-right:5px;',
			border:false,
			defaults:{
				border:false,
				xtype:'textfield',
				anchor:'100%'
			},
			items:[{
				xtype:'textfield',
				name: "roomProject.address",
				fieldLabel:'项目地址'
			}]
		},{
			columnWidth : .25,
			layout : 'form',
			bodyStyle:'padding-right:5px;',
			border:false,
			defaults : {
				border:false,
				xtype : 'textfield',
				anchor : '100%'
			},
			items:[{
				xtype: "combo",
	            id: "areaTypeCombo",
	            editable: false,
	            readOnly:true,
	            fieldLabel :'<font color=red>*</font>区域性质',
	            allowBlank:false,
	            valueField: "roomProject.areaType.id",
	            displayField: "areaTypeText",
	            hiddenName: "roomProject.areaType.id",
	            store: new Ext.data.SimpleStore({
	            	fields:['roomProject.areaType.id','areaTypeText'],
					data:[
							['26','普通小高层小区'],
							['27','高档小高层小区'],
							['28','普通高层小区'],
							['29','高档高层小区'],
							['30','大型商场'],
							['31','中型商场'],
							['32','小型商场'],
							['33','室外商业街区'],
							['34','大型办公楼'],
							['35','中型办公楼'],
							['36','普通办公楼'],
							['37','小型办公楼'],
							['38','五星级宾馆'],
							['39','四星级宾馆'],
							['40','三星级宾馆'],
							['41','二星级及以下宾馆'],
							['42','娱乐休闲场所'],
							['43','地下空间休闲场所'],
							['44','餐饮场所'],
							['45','农居点'],
							['46','工业园区'],
							['47','校园'],
							['48','隧道'],
							['49','景区'],
							['50','大型桥梁'],
							['51','干扰区域'],
							['52','行政村'],
							['53','自然村'],
							['54','车站码头'],
							['55','专业市场'],
							['56','多层'],
							['57','电梯'],
							['58','其他营业场所'],
							['59','其他地下场所'],
							['60','无需覆盖区域'],
							['61','普通道路'],
							['62','大型医院'],
							['63','小型医院'],
							['64','中型医院'],
							['65','二级甲等以上'],
							['66','二级甲等以下'],
							['67','其它']
						]
	            }),
	            mode: "local",
	            triggerAction: "all",
	            emptyText:'请选择区域性质...'
			},{
				xtype:'combo',
				fieldLabel:'<font color=red>*</font>是否新建',
				readOnly : true,
				editable : false,
				allowBlank:false,
				mode:'local',
				triggerAction : 'all',
				hiddenName:'roomProject.newCreate',
				valueField : 'roomProject.newCreate',
				displayField : 'iscreateDisplay',
				store: new Ext.data.SimpleStore({
					fields:['roomProject.newCreate','iscreateDisplay'],
					data:[['是','是'],['否','否']]
				}),
				emptyText:'请选择是否新建...',
				listeners:{
					select:function(){
						var rc=Ext.getCmp('relatedcode');
						if(this.getValue() == '是'){
							if(rc){
								rc.setVisible(false);
								rc.allowBlank=true;
								rc.el.dom.parentNode.parentNode.firstChild.innerHTML ='';
							}
						}else{
							if(rc){
								rc.el.dom.parentNode.parentNode.firstChild.innerHTML ='<font color=red>*</font>关联项目编号:';
								rc.setVisible(true);
								rc.allowBlank=false;
								
							}
						}
					}
				}
			},{
				xtype:'combo',
				hiddenName:'roomProject.liftSignal',
				fieldLabel:'电梯信号',
				readOnly : true,
				editable : false,
				mode:'local',
				triggerAction : 'all',
				valueField : 'roomProject.liftSignal',
				displayField : 'dtxhDisplay',
				store: new Ext.data.SimpleStore({
					fields:['roomProject.liftSignal','dtxhDisplay'],
					data:[['覆盖良好','覆盖良好'],['无覆盖','无覆盖'],['弱覆盖','弱覆盖'],['部分无覆盖','部分无覆盖'],['部分弱覆盖','部分弱覆盖'],['覆盖一般','覆盖一般']]
				}),
				emptyText:'请选择电梯信号...'
			},{
				xtype: "numberfield",
	            name: "roomProject.underParkNumber",
	            allowNegative:false,
	            allowDecimals:false,
	            minValue:0,
	            fieldLabel:'独立地下车库数量'
			}]
		},{
			columnWidth : .25,
			layout : 'form',
			bodyStyle:'padding-left:5px;',
			border:false,
			defaults : {
				border:false,
				xtype : 'textfield',
				anchor : '100%'
			},
			items:[{
				xtype:'textfield',
				name: "roomProject.lon",
	            fieldLabel:'<font color=red>*</font>经度',
	            allowBlank:false,
	            vtype:'long'
			},{
				id:'relatedcode',
				xtype:'textfield',
				name: "roomProject.relatedCode",
				hidden:false,
				hideLabel:false,
				allowBlank:true,
				fieldLabel:'关联项目编号'
			},{
				xtype: "numberfield",
	            name: "roomProject.liftNumber",
	            fieldLabel:'电梯数量',
	            allowNegative:false,
	            allowDecimals:false,
	            minValue:0
			},{
				xtype: "numberfield",
	            name: "roomProject.underParkCarNumber",
	            allowNegative:false,
	            allowDecimals:false,
	            minValue:0,
	            fieldLabel:'地下车库车位数量'
			}]
		},{
			columnWidth : .25,
			layout : 'form',
			bodyStyle:'padding-left:5px;',
			border:false,
			defaults : {
				border:false,
				xtype : 'textfield',
				anchor : '100%'
			},
			items:[{
				xtype:'textfield',
				name: "roomProject.lat",
	            fieldLabel:'<font color=red>*</font>纬度',
	            allowBlank:false,
	            vtype:'lat'
			},{
				xtype:'lovcombo',
				hiddenName:'roomProject.resolveContent',
				fieldLabel:'解决内容',
				valueField:'roomProject.resolveContent',
				displayField:'jjnrDisplay',
				readOnly : false,
				editable : true,
				mode:'local',
				triggerAction : 'all',
				store:new Ext.data.SimpleStore({
					fields:['roomProject.resolveContent','jjnrDisplay'],
					data:[
						['主体','主体'],
						['电梯','电梯'],
						['地下室','地下室'],
						['分布+外挂','分布+外挂'],
						['小区分布','小区分布']
					]
				}),
				emptyText:'请选择解决内容...'
			},{
				xtype: "numberfield",
	            name: "roomProject.liftTopFloor",
	            fieldLabel:'电梯最高层数',
	            allowNegative:false,
	            allowDecimals:false,
	            minValue:0
			},{
				xtype: "numberfield",
				fieldLabel:'预计覆盖面积(㎡)',
	            name: "roomProject.coverArea",
	            allowNegative:false,
	            minValue:0
			}]
		},{
			columnWidth : .25,
			layout : 'form',
			bodyStyle:'padding-left:5px;',
			border:false,
			defaults : {
				border:false,
				xtype : 'textfield',
				anchor : '100%'
			},
			items:[{
				xtype: "combo",
	            id: "projectTypeCombo",
	            editable: false,
	            readOnly:true,
	            fieldLabel :'<font color=red>*</font>项目分类',
	            allowBlank:false,
	            valueField: "roomProject.projectType.id",
	            displayField: "projectTypeText",
	            hiddenName: "roomProject.projectType.id",
	            store: new Ext.data.SimpleStore({
	            	fields:['roomProject.projectType.id','projectTypeText'],
	            	data:[
	       					['16','解决VIP投诉'],
	    					['17','新区跟进'],
	    					['18','话务吸收'],
	    					['19','深度覆盖'],
	    					['20','解决普通投诉'],
	    					['21','解决弱覆盖'],
	    					['22','解决质差问题'],
	    					['23','道路覆盖'],
	    					['24','解决高层投诉'],
	    					['69','室内分布专项优化'],
	    					['70','解决城区覆盖调查弱覆盖'],
	    					['71','解决A类集团弱覆盖'],
	    					['72','解决大客户投诉'],
	    					['73','容量站、风景区覆盖、网络质量提升'],
	    					['74','华为替换二阶段室分叠加1800项目'],
	    					['68','其它']
	    				]
	            }),
	            mode: "local",
	            triggerAction: "all",
	            emptyText:'请选择项目分类...'
			},{
				xtype:'combo',
				hiddenName:'roomProject.mainSignal',
				valueField:'roomProject.mainSignal',
				displayField:'ztxxDisplay',
				fieldLabel:'主体信息',
				readOnly : true,
				editable : false,
				mode:'local',
				triggerAction : 'all',
				store:new Ext.data.SimpleStore({
					fields:['roomProject.mainSignal','ztxxDisplay'],
					data:[['覆盖良好','覆盖良好'],['无覆盖','无覆盖'],['弱覆盖','弱覆盖'],['部分无覆盖','部分无覆盖'],['部分弱覆盖','部分弱覆盖'],['覆盖一般','覆盖一般']]
				}),
				emptyText:'请选择主体信息...'
			},{
				xtype:'combo',
				fieldLabel:'地下车库信号',
				hiddenName:'roomProject.underParkSignal',
				valueField:'roomProject.underParkSignal',
				displayField:'dxckxhDisplay',
				readOnly : true,
				editable : false,
				mode:'local',
				triggerAction : 'all',
				store:new Ext.data.SimpleStore({
					fields:['roomProject.underParkSignal','dxckxhDisplay'],
					data:[['覆盖良好','覆盖良好'],['无覆盖','无覆盖'],['弱覆盖','弱覆盖'],['部分弱覆盖','部分弱覆盖'],['覆盖一般','覆盖一般']]
				}),
				emptyText:'请选择地下车库信号...'
			},{
				xtype:'combo',
				hiddenName:'roomProject.emergencyLevel',
				fieldLabel:'<font color=red>*</font>紧急程度',
				readOnly : true,
				editable : false,
				mode:'local',
				triggerAction : 'all',
				valueField : 'roomProject.emergencyLevel',
				displayField : 'jjDisplay',
				store: new Ext.data.SimpleStore({
					fields:['roomProject.emergencyLevel','jjDisplay'],
					data:[['可缓','可缓'],['一般','一般'],['紧急','紧急']]
				}),
				emptyText:'请选择紧急程度...'
			}]
		},{
			columnWidth:1,
			layout:'form',
			bodyStyle:'padding-right:5px;',
			border:false,
			defaults:{
				border:false,
				anchor:'100%'
			},
			items:{
				xtype: 'checkboxgroup',
	            fieldLabel: '<font color=red>*</font>网络制式',
	            allowBlank : false,
	            labelAlign:'left',
	            items: [
	                {id:'gsm',boxLabel: 'GSM', name: 'roomProject.netType', inputValue : 'GSM',
		                listeners:{
		                	check:function(){
		                		var bizNumber=Ext.getCmp('bizNumber').getValue();
	                			var td=Ext.getCmp('td');
	                			var lte=Ext.getCmp('lte');
	                			var gsmTerm=Ext.getCmp('gsmTerm');
	                			var gsmBuild=Ext.getCmp('gsmBuild');
	                			var temp=bizNumber.substring(4);
		                		if(this.checked==true){
		                			gsmTerm.enable();
		                			gsmBuild.enable();
		                			Ext.getCmp('bizNumber').setValue('GXXX'+temp);
		                			if(this.checked && td.checked){
		                				Ext.getCmp('bizNumber').setValue('GTXX'+temp);
		                			}
		                			if(this.checked && lte.checked){
		                				Ext.getCmp('bizNumber').setValue('GXLX'+temp);
		                			}
		                			if(this.checked && td.checked && lte.checked){
		                				Ext.getCmp('bizNumber').setValue('GTLX'+temp);
		                			}
		                			Ext.getCmp('wlan').disable();
		                		}else{
		                			gsmTerm.disable();
		                			gsmBuild.disable();
		                			Ext.getCmp('bizNumber').setValue('XXXX'+temp);
		                			if(td.checked){
		                				Ext.getCmp('bizNumber').setValue('XTXX'+temp);
		                			}
		                			if(lte.checked){
		                				Ext.getCmp('bizNumber').setValue('XXLX'+temp);
		                			}
		                			if(td.checked && lte.checked){
		                				Ext.getCmp('bizNumber').setValue('XTLX'+temp);
		                			}
		                			if(!td.checked && !lte.checked){
		                				Ext.getCmp('bizNumber').setValue('XXXX'+temp);
		                				Ext.getCmp('wlan').enable();
		                			}
		                		}
		                	}
		                }
	                },
	                {id:'td',boxLabel: 'TD-SCDMA', name: 'roomProject.netType', inputValue : 'TD',
	                	listeners:{
		                	check:function(){
		                		var bizNumber=Ext.getCmp('bizNumber').getValue();
	                			var gsm=Ext.getCmp('gsm');
	                			var lte=Ext.getCmp('lte');
	                			var tdTerm=Ext.getCmp('tdTerm');
	                			var tdBuild=Ext.getCmp('tdBuild');
	                			var temp=bizNumber.substring(4);
		                		if(this.checked==true){
		                			tdTerm.enable();
		                			tdBuild.enable();
		                			Ext.getCmp('bizNumber').setValue('XTXX'+temp);
		                			if(this.checked && gsm.checked){
		                				Ext.getCmp('bizNumber').setValue('GTXX'+temp);
		                			}
		                			if(this.checked && lte.checked){
		                				Ext.getCmp('bizNumber').setValue('XTLX'+temp);
		                			}
		                			if(this.checked && gsm.checked && lte.checked){
		                				Ext.getCmp('bizNumber').setValue('GTLX'+temp);
		                			}
		                			Ext.getCmp('wlan').disable();
		                		}else{
		                			tdTerm.disable();
		                			tdBuild.disable();
		                			Ext.getCmp('bizNumber').setValue('XXXX'+temp);
		                			if(gsm.checked){
		                				Ext.getCmp('bizNumber').setValue('GXXX'+temp);
		                			}
		                			if(lte.checked){
		                				Ext.getCmp('bizNumber').setValue('XXLX'+temp);
		                			}
		                			if(gsm.checked && lte.checked){
		                				Ext.getCmp('bizNumber').setValue('GXLX'+temp);
		                			}
		                			if(!gsm.checked && !lte.checked){
		                				Ext.getCmp('bizNumber').setValue('XXXX'+temp);
		                				Ext.getCmp('wlan').enable();
		                			}
		                		}
		                	}
		                }
	                },
	                {id:'lte',boxLabel: 'LTE', name: 'roomProject.netType', inputValue : 'LTE',
	                	listeners:{
		                	check:function(){
		                		var bizNumber=Ext.getCmp('bizNumber').getValue();
	                			var gsm=Ext.getCmp('gsm');
	                			var td=Ext.getCmp('td');
	                			var lteTerm=Ext.getCmp('lteTerm');
	                			var lteBuild=Ext.getCmp('lteBuild');
	                			var temp=bizNumber.substring(4);
		                		if(this.checked==true){
		                			lteTerm.enable();
		                			lteBuild.enable();
		                			Ext.getCmp('bizNumber').setValue('XXLX'+temp);
		                			if(this.checked && td.checked){
		                				Ext.getCmp('bizNumber').setValue('XTLX'+temp);
		                			}
		                			if(this.checked && gsm.checked){
		                				Ext.getCmp('bizNumber').setValue('GXLX'+temp);
		                			}
		                			if(this.checked && td.checked && gsm.checked){
		                				Ext.getCmp('bizNumber').setValue('GTLX'+temp);
		                			}
		                			Ext.getCmp('wlan').disable();
		                		}else{
		                			lteTerm.disable();
		                			lteBuild.disable();
		                			Ext.getCmp('bizNumber').setValue('XXXX'+temp);
		                			if(gsm.checked){
		                				Ext.getCmp('bizNumber').setValue('GXXX'+temp);
		                			}
		                			if(td.checked){
		                				Ext.getCmp('bizNumber').setValue('XTXX'+temp);
		                			}
		                			if(gsm.checked && td.checked){
		                				Ext.getCmp('bizNumber').setValue('GTXX'+temp);
		                			}
		                			if(!gsm.checked && !td.checked){
		                				Ext.getCmp('bizNumber').setValue('XXXX'+temp);
		                				Ext.getCmp('wlan').enable();
		                			}
		                		}
		                	}
		                }
	                },
	                {id:'wlan',boxLabel: 'WLAN', name: 'roomProject.netType', inputValue : 'WLAN',
	                listeners:{
		                	check:function(){
		                		var bizNumber=Ext.getCmp('bizNumber').getValue();
		                		var wlanTerm=Ext.getCmp('wlanTerm');
		                		var wlanBuild=Ext.getCmp('wlanBuild');
		                		var temp=bizNumber.substring(4);
		                		if(this.checked==true){
		                			Ext.getCmp('bizNumber').setValue('XXXW'+temp);
		                			Ext.getCmp('gsm').disable();
		                			Ext.getCmp('td').disable();
		                			Ext.getCmp('lte').disable();
		                			wlanTerm.enable();
		                			wlanBuild.enable();
		                		}else{
		                			Ext.getCmp('bizNumber').setValue('XXXX'+temp);
		                			Ext.getCmp('gsm').enable();
		                			Ext.getCmp('td').enable();
		                			Ext.getCmp('lte').enable();
		                			wlanTerm.disable();
		                			wlanBuild.disable();
		                		}
		                	}
		                }
	                }
	            ]
			}
		},{
			columnWidth : .25,
			layout : 'form',
			bodyStyle:'padding-right:5px;',
			border:false,
			defaults : {
				border:false,
				anchor : '100%'
			},
			items:[{
				id:'gsmTerm',
				xtype:'combo',
				hiddenName:'roomProject.gsmTerm',
				fieldLabel:'<font color=red>*</font>GSM期数',
				allowBlank : false,
				readOnly : true,
				editable : false,
				disabled : true,
				mode:'local',
				triggerAction : 'all',
				valueField : 'roomProject.gsmTerm',
				displayField : 'gsmterm',
				store: new Ext.data.SimpleStore({
					fields:['roomProject.gsmTerm','gsmterm'],
					data:[
						['G17','G17'],
						['G18','G18'],
						['G18.1','G18.1'],
						['G18.2','G18.2'],
						['G19','G19'],
						['遗留站点','遗留站点'],
						['双百站点','双百站点']
					]
				}),
				emptyText:'请选择GSM期数...'
			},{
				id:'gsmBuild',
				xtype:'combo',
				fieldLabel:'<font color=red>*</font>GSM建设方式',
				hiddenName:'roomProject.gsmBuildType',
				allowBlank : false,
				readOnly : true,
				editable : false,
				disabled : true,
				mode:'local',
				triggerAction : 'all',
				valueField : 'roomProject.gsmBuildType',
				displayField : 'gsmtype',
				store: new Ext.data.SimpleStore({
					fields:['roomProject.gsmBuildType','gsmtype'],
					data:[
						['主设备','主设备'],
						['基站耦合','基站耦合'],
						['光纤直放站','光纤直放站'],
						['分布直放站改造','分布直放站改造'],
						['室内专项优化','室内专项优化'],
						['GRRU','GRRU'],
						['无线直放站','无线直放站'],
						['RRU拉远','RRU拉远'],
						['主设备分布','主设备分布'],
						['新建室外直放站','新建室外直放站'],
						['直放站分布','直放站分布'],
						['分布加新建室外直放站','分布加新建室外直放站']
					]
				}),
				emptyText:'请选择建设方式...'
			}]
		},{
			columnWidth : .25,
			layout : 'form',
			bodyStyle:'padding-left:5px;',
			border:false,
			defaults : {
				border:false,
				anchor : '100%'
			},
			items:[{
				id:'tdTerm',
				xtype:'combo',
				hiddenName:'roomProject.tdTerm',
				fieldLabel:'<font color=red>*</font>TD期数',
				allowBlank : false,
				readOnly : true,
				editable : false,
				disabled : true,
				mode:'local',
				triggerAction : 'all',
				valueField : 'roomProject.tdTerm',
				displayField : 'tdterm',
				store: new Ext.data.SimpleStore({
					fields:['roomProject.tdTerm','tdterm'],
					data:[
						['T4','T4'],
						['T5','T5']
					]
				}),
				emptyText:'请选择TD期数...'
			},{
				id:'tdBuild',
				xtype:'combo',
				fieldLabel:'<font color=red>*</font>TD建设方式',
				hiddenName:'roomProject.tdBuildType',
				allowBlank : false,
				readOnly : true,
				editable : false,
				disabled : true,
				mode:'local',
				triggerAction : 'all',
				valueField : 'roomProject.tdBuildType',
				displayField : 'tdtype',
				store: new Ext.data.SimpleStore({
					fields:['roomProject.tdBuildType','tdtype'],
					data:[
						['合路','合路'],
						['单独天馈','单独天馈']
					]
				}),
				emptyText:'请选择建设方式...'
			}]
		},{
			columnWidth : .25,
			layout : 'form',
			bodyStyle:'padding-left:5px;',
			border:false,
			defaults : {
				border:false,
				anchor : '100%'
			},
			items:[{
				id:'lteTerm',
				xtype:'combo',
				hiddenName:'roomProject.lteTerm',
				fieldLabel:'<font color=red>*</font>LTE期数',
				allowBlank : false,
				readOnly : true,
				editable : false,
				disabled : true,
				mode:'local',
				triggerAction : 'all',
				valueField : 'roomProject.lteTerm',
				displayField : 'lteterm',
				store: new Ext.data.SimpleStore({
					fields:['roomProject.lteTerm','lteterm'],
					data:[
						['试验','试验']
					]
				}),
				emptyText:'请选择LTE期数...'
			},{
				id:'lteBuild',
				xtype:'combo',
				fieldLabel:'<font color=red>*</font>LTE建设方式',
				hiddenName:'roomProject.lteBuildType',
				allowBlank : false,
				readOnly : true,
				editable : false,
				disabled : true,
				mode:'local',
				triggerAction : 'all',
				valueField : 'roomProject.lteBuildType',
				displayField : 'ltetype',
				store: new Ext.data.SimpleStore({
					fields:['roomProject.lteBuildType','ltetype'],
					data:[
						['单独改造','单独改造'],
						['新建单路','新建单路'],
						['新建双路','新建双路']
					]
				}),
				emptyText:'请选择建设方式...'
			}]
		},{
			columnWidth : .25,
			layout : 'form',
			bodyStyle:'padding-left:5px;',
			border:false,
			defaults : {
				border:false,
				anchor : '100%'
			},
			items:[{
				id:'wlanTerm',
				xtype:'combo',
				hiddenName:'roomProject.wlanTerm',
				fieldLabel:'<font color=red>*</font>WLAN期数',
				allowBlank : false,
				readOnly : true,
				editable : false,
				disabled : true,
				mode:'local',
				triggerAction : 'all',
				valueField : 'roomProject.wlanTerm',
				displayField : 'wlanterm',
				store: new Ext.data.SimpleStore({
					fields:['roomProject.wlanTerm','wlanterm'],
					data:[
						['W1','W1'],
						['W2','W2'],
						['W3','W3']
					]
				}),
				emptyText:'请选择WLAN期数...'
			},{
				id:'wlanBuild',
				xtype:'combo',
				fieldLabel:'<font color=red>*</font>WLAN建设方式',
				hiddenName:'roomProject.wlanBuildType',
				allowBlank : false,
				readOnly : true,
				editable : false,
				disabled : true,
				mode:'local',
				triggerAction : 'all',
				valueField : 'roomProject.wlanBuildType',
				displayField : 'wlantype',
				store: new Ext.data.SimpleStore({
					fields:['roomProject.wlanBuildType','wlantype'],
					data:[
						['合路','合路'],
						['单独天馈','单独天馈']
					]
				}),
				emptyText:'请选择建设方式...'
			}]
		},{
			columnWidth:1,
			layout:'form',
			bodyStyle:'padding-right:5px;',
			border:false,
			defaults:{
				border:false,
				anchor:'100%'
			},
			items:[{
				xtype:'textarea',
				name:'roomProject.remark',
				fieldLabel:'备注信息'
			}]
		}]
    });
};

Ext.extend(BasicInfoPanel, Ext.Panel);

ComplaintPanel = function(){
    this.dataStore = new Ext.data.ArrayStore({
    	fields: [{
            name: "id"
        }, {
            name: "imepId"
        }, {
            name: "woId"
        }, {
            name: "dealTime"
        }, {
            name: "customerName"
        }, {
            name: "customerMobile"
        }, {
            name: "complaintContent"
        }, {
            name: "address"
        }, {
            name: "reason"
        }, {
            name: "longitude"
        }, {
            name: "latitude"
        }, {
            name: "resolve"
        }],
        listeners: {
            update: function(store, record, operation){
            
            }
        }
    });
    
    var columns = [{
        header: "投诉工单号",
        dataIndex: "imepId",
        sortable: true
    }, {
        header: "工单流水号",
        dataIndex: "woId",
        sortable: true
    }, {
        header: "受理时间",
        dataIndex: "dealTime",
        sortable: true,
        align: "right"
    }, {
        header: "用户姓名",
        dataIndex: "customerName",
        sortable: true
    }, {
        header: "用户手机号",
        dataIndex: "customerMobile",
        sortable: true
    }, {
        header: "投诉内容",
        hidden:true,
        dataIndex: "complaintContent",
        sortable: true
    }, {
        header: "投诉地址",
        dataIndex: "address",
        sortable: true,
        id:"address"
    }, {
        header: "投诉原因",
        dataIndex: "reason",
        sortable: true,
        id:"reason",
        align: "right"
    }, {
        header: "经度",
        dataIndex: "longitude",
        sortable: true,
        hidden:true,
        id:"lon",
        align: "right"
    }, {
        header: "纬度",
        dataIndex: "latitude",
        sortable: true,
        hidden:true,
        id:"latitude",
        align: "right"
    }, {
        header: "是否解决",
        dataIndex: "resolve",
        hidden:true,
        sortable: true,
        id:"resolve"
    }, {
        header: "主键",
        id: "id",
        hidden:true,
        dataIndex: "id"
    }];
    
    ComplaintPanel.superclass.constructor.call(this, {
        id: "complaintPanel",
        title: "关联投诉信息",
        frame: true,
        // plugins: [editor],
        anchor:'100%',
        width:'100%',
        height: 180,
        stripeRows: true,
        store: this.dataStore,
        autoExpandColumn: "id",
        columns: columns,
        sm:new Ext.grid.RowSelectionModel({singeSelect:true}),
        tbar: [{
            text: "增加关联",
            iconCls: "silk-add",
            scope: this,
            handler: function(){
        	   // var complaintWindow = new ComplaintWindow();
        	   // complaintWindow.setTitle("关联投诉信息");
        	   // complaintWindow.show();
        	
        	var params = {};
        	var popup = PopupManager.getComplaintPopup(params,
        			function(r){
		        		var dataStore = Ext.getCmp("complaintPanel").dataStore;
		                var e = new dataStore.recordType({
		                    id: r.id,
		                    imepId: r.imepId,
		                    woId: r.woId,
		                    dealTime: r.dealTime,
		                    customerName: r.customerName,
		                    customerMobile: r.customerMobile,
		                    complaintContent: r.complaintContent,
		                    address: r.address,
		                    reason: r.reason,
		                    longitude: r.longitude,
		                    latitude: r.latitude,
		                    resolve: r.resolve
		                });
		                
		                var count = dataStore.getCount();
		                if(count==0){
		                	dataStore.insert(0, e);
		                	Ext.getCmp("complaintPanel").view.refresh();
		                }else{
				            for (var i = 0;i<count;i++) {
				            	//debugger;
			                    if (dataStore.getAt(i).get("imepId") == r.imepId) {
			                       Ext.Msg.show({
			                       		title:'提示',
			                       		msg:'该数据已经关联过！',
			                       		buttons : Ext.MessageBox.OK,
										icon : Ext.MessageBox.INFO
			                       })
			                    }else{
			                    	dataStore.insert(0,e);
			                    	Ext.getCmp("complaintPanel").view.refresh();
			                    }
				            }
		                }
        			}
        	);
            }
        }, "-", {
            text: "删除关联",
            iconCls: "silk-delete",
            handler: function(){
                var grid = Ext.getCmp("complaintPanel");
                var s = grid.getSelectionModel().getSelections();
                for (var i = 0, r; r = s[i]; i++) {
//                    if (r.data.id) {
//                        grid.toBeDelSoiIds.push(r.data.id);
//                    }
                    grid.dataStore.remove(r);
                }
            }
        }, "-"],
        
        listeners: {
            rowdblclick: function(){
                var grid = Ext.getCmp("soiPanel");
                if(grid){
                	var r = grid.getSelectionModel().getSelected();
	                var soiWindow = new SoiWindow(r);
	                soiWindow.setTitle(Ext.getCmp('settlementtype').getValue());
	                soiWindow.show();
                }
            }
        }
    });
    
}
Ext.extend(ComplaintPanel, Ext.grid.GridPanel, {
});

